package com.mark.anto.bootstrap;

import com.mark.anto.repository.MyFirstLevelRepository;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.util.Assert;

/**
 * @Description: 自定义模式注解的引导类
 * @Author: Mark
 * @CreateDate: 2019/9/1 0:07
 * @Version: 3.00.001
 * @Copyright : 豆浆油条个人非正式工作室
 */
@ComponentScan(basePackages = "com.mark.anto.repository")
public class RepositoryBootstrap {

    public static void main(String[] args) {
        ConfigurableApplicationContext context = new SpringApplicationBuilder(RepositoryBootstrap.class)
                .web(WebApplicationType.NONE)
                .run(args);

        //从上下文中获取Bean
        MyFirstLevelRepository bean = context.getBean("myFirstLevelRepository", MyFirstLevelRepository.class);
        Assert.notNull(bean, "获取到Bean为为空！");

        //关闭上下文
        context.close();
    }
}
